package cn.kimming.rpc.common.util;

public class MyRpcUtils {


	/**
	 * 从SystemProperty中读取变量
	 * 若SystemProperty中不存在, 则从环境变量Env中读取
	 * 若环境变量中不存在, 返回默认值
	 */
	public static <T> T getPropertyFromSystemPropOrEnv(String propertyName, Class<T> propType, T defaultValue) {
		String value = System.getProperty(propertyName);
		if (value != null) {
			return (T) value;
		}

		value = System.getenv(propertyName);
		if (value != null) {
			return (T) value;
		}

		return defaultValue;
	}
}
